<template>
  <div>
    <h1>租房解约信息</h1>
    <!--租房解约信息查询-->
    <el-form :inline="true" :model="formInline" class="demo-form-inline">
      <el-form-item label="解约合同编号">
        <el-input v-model="formInline.cfTerminationNo" placeholder="解约合同编号" />
      </el-form-item>

      <el-form-item label="录入人">
        <el-input v-model="formInline.inputUserName" placeholder="录入人" />
      </el-form-item>

      <el-form-item label="小区名称">
        <el-input v-model="formInline.premiseName" placeholder="小区名称" />
      </el-form-item>

      <el-form-item label="协议录入日期">
        <el-col :span="11">
          <el-date-picker v-model="formInline.inputDate1" type="date" placeholder="选择日期" value-format="yyyy-MM-dd" style="width: 100%;" />
        </el-col>
        <el-col class="line" :span="2">至</el-col>
        <el-col :span="11">
          <el-date-picker v-model="formInline.inputDate2" type="date" placeholder="选择日期" value-format="yyyy-MM-dd" style="width: 100%;" />
        </el-col>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="TerminateList()">查询</el-button>
        <el-button type="primary" @click="resetForm()">清空</el-button>
      </el-form-item>
    </el-form>
    <!--列表展示-->
    <el-table
      :data="tableData"
      border
      style="width: 100%"
    >
      <el-table-column
        prop="cfTerminationNo"
        label="解约合同编号"
        width="220"
      />
      <el-table-column
        prop="premiseName"
        label="小区名称"
        width="150"
      />
      <el-table-column
        label="解约类型"
        width="150"
      >
        <template slot-scope="scope">
          <span v-if="scope.row.terminationType==1">
            <el-button type="success" size="mini">合同到期</el-button>
          </span>
          <span v-if="scope.row.terminationType==2">
            <el-button type="danger" size="mini">租客提前解约</el-button>
          </span>
          <span v-if="scope.row.terminationType==3">
            <el-button type="info" size="mini">我方退租解约</el-button>
          </span>
          <span v-if="scope.row.terminationType==4">
            <el-button type="primary" size="mini">其他</el-button>
          </span>
        </template>
      </el-table-column>
      <el-table-column
        prop="terminationDate"
        label="解约日期"
        width="150"
      />
      <el-table-column
        prop="auditDate"
        label="审核日期"
        width="150"
      />
      <el-table-column
        prop="finalStatement"
        label="结算金额"
        width="150"
      />
      <el-table-column
        prop="inputDate"
        label="录入日期"
        width="150"
      />
      <el-table-column
        prop="inputUserName"
        label="录入人"
        width="250"
      />
    </el-table>
    <!--分页展示-->
    <el-pagination
      background
      :current-page="pageNum"
      :page-sizes="[5, 10, 15, 20]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />

  </div>
</template>

<script>
export default {
  name: 'Terminate',
  data() {
    return {
      // 列表
      tableData: [],
      // 分页
      pageNum: 1,
      pageSize: 5,
      total: 0,
      // 查询
      formInline: {}
    }
  },
  created() {
    this.TerminateList()
  },
  methods: {
    // 列表
    TerminateList() {
      this.axios.get('http://localhost:9999/house-resource/tCfTermination/list', {
        params: {
          pageNum: this.pageNum,
          pageSize: this.pageSize,
          inputUserName: this.formInline.inputUserName,
          cfTerminationNo: this.formInline.cfTerminationNo,
          premiseName: this.formInline.premiseName,
          inputDate1: this.formInline.inputDate1,
          inputDate2: this.formInline.inputDate2
        }
      }).then((response) => {
        console.log(response.data)
        this.tableData = response.data.obj.list
        this.total = response.data.obj.total
      })
    },
    // 分页
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`)
      this.pageSize = val
      this.TerminateList()
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`)
      this.pageNum = val
      this.TerminateList()
    },

    // 清空
    resetForm() {
      this.formInline = {}
    }
  }

}
</script>

